package _interview75;

/**
 * 605. 种花问题
 */
public class No605 {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        int[] arr = new int[flowerbed.length + 2];
        System.arraycopy(flowerbed, 0, arr, 1, flowerbed.length);
        for (int i = 1; i < arr.length - 1; i++) {
            if (arr[i - 1] == 0 && arr[i] == 0 && arr[i + 1] == 0) {
                arr[i] = 1; // 种花！
                n--;
            }
        }
        return n <= 0;
    }
}
